<?php
require_once realpath(dirname(__FILE__)) . '/../include/version.php';

$ss_class = array(0 => 'even', 1 => 'odd');
$count = 0;

/* ------------------------------------------------------------------ */
xoops_cp_header() ;
include dirname(__FILE__).'/mymenu.php' ;

echo '<h3>'. h($xoopsModule->getVar('name')) .' - '. constant($constprefMI .'_ADMENU0') .'</h3>';

// flatdata
echo '<table cellpadding="5" border="1" style="border-collapse:collapse;empty-cells:show; border-color:#666;margin:10px 0 10px 0;width:100%;">';
echo '<tr><th colspan="2">FLATDATA</th></tr>';
echo '<tr><td class="head" width="300">VERSION</td><td class="'. $ss_class[$count++%2] .'">'. __FLATDATA_VERSION .'</td></tr>';
echo '</table>';

// XCL
echo '<table cellpadding="5" border="1" style="border-collapse:collapse;empty-cells:show; border-color:#666;margin:10px 0 10px 0;width:100%;">';
echo '<tr><th colspan="2">XCL</th></tr>';
echo '<tr><td class="head" width="300">XOOPS_VERSION</td><td class="'. $ss_class[$count++%2] .'">'. XOOPS_VERSION .'</td></tr>';
echo '<tr><td class="head">_CHARSET</td><td class="'. $ss_class[$count++%2] .'">'. _CHARSET .'</td></tr>';
echo '</table>';

// SERVER
echo '<table cellpadding="5" border="1" style="border-collapse:collapse;empty-cells:show; border-color:#666;margin:10px 0 10px 0;width:100%;">';
echo '<tr><th colspan="2">SERVER</th></tr>';
echo '<tr><td class="head" width="300">SERVER_SOFTWARE</td><td class="'. $ss_class[$count++%2] .'">'. h($_SERVER['SERVER_SOFTWARE']) .'</td></tr>';
echo '<tr><td class="head" width="300">SERVER_SIGNATURE</td><td class="'. $ss_class[$count++%2] .'">'. h($_SERVER['SERVER_SIGNATURE']) .'</td></tr>';
echo '</table>';
 
// PHP
echo '<table cellpadding="5" border="1" style="border-collapse:collapse;empty-cells:show; border-color:#666;margin:10px 0 10px 0;width:100%;">';
echo '<tr><th colspan="2">PHP</th></tr>';
echo '<tr><td class="head" width="300">PHP_VERSION</td><td class="'. $ss_class[$count++%2] .'">'. PHP_VERSION .'</td></tr>';
echo '<tr><td class="head">safe_mode</td><td class="'. $ss_class[$count++%2] .'">'. h(ini_get('safe_mode')) .'</td></tr>';
echo '<tr><td class="head">memory_limit</td><td class="'. $ss_class[$count++%2] .'">'. h(ini_get('memory_limit')) .'</td></tr>';
echo '<tr><td class="head">register_globals</td><td class="'. $ss_class[$count++%2] .'">'. h(ini_get('register_globals')) . '</td></tr>';
echo '<tr><td class="head">default_charset</td><td class="'. $ss_class[$count++%2] .'">'. h(ini_get('default_charset')) .'</td></tr>';
echo '<tr><td class="head">output_buffering</td><td class="'. $ss_class[$count++%2] .'">'. h(ini_get('output_buffering')) .'</td></tr>';
echo '<tr><td class="head">output_handler</td><td class="'. $ss_class[$count++%2] .'">'. h(ini_get('output_handler')) .'</td></tr>';
	// mbstring
echo '<tr><td class="head">mbstring.language</td><td class="'. $ss_class[$count++%2] .'">'. h(ini_get('mbstring.language')) .'</td></tr>';
echo '<tr><td class="head">mbstring.internal_encoding</td><td class="'. $ss_class[$count++%2] .'">'. h(ini_get('mbstring.internal_encoding')) .'</td></tr>';
echo '<tr><td class="head">mbstring.http_input</td><td class="'. $ss_class[$count++%2] .'">'. h(ini_get('mbstring.http_input')) .'</td></tr>';
echo '<tr><td class="head">mbstring.http_output</td><td class="'. $ss_class[$count++%2] .'">'. h(ini_get('mbstring.http_output')) .'</td></tr>';
echo '<tr><td class="head">mbstring.detect_order</td><td class="'. $ss_class[$count++%2] .'">'. h(ini_get('mbstring.detect_order')) .'</td></tr>';
echo '<tr><td class="head">mbstring.encoding_translation</td><td class="'. $ss_class[$count++%2] .'">'. h(ini_get('mbstring.encoding_translation')) .'</td></tr>';
echo '<tr><td class="head">mbstring.func_overload</td><td class="'. $ss_class[$count++%2] .'">'. h(ini_get('mbstring.func_overload')) .'</td></tr>';
echo '<tr><td class="head">mbstring.strict_detection</td><td class="'. $ss_class[$count++%2] .'">'. h(ini_get('mbstring.strict_detection')) .'</td></tr>';
echo '<tr><td class="head">mbstring.substitute_character</td><td class="'. $ss_class[$count++%2] .'">'. h(ini_get('mbstring.substitute_character')) .'</td></tr>';
echo '</table>';

// MySQL
echo '<table cellpadding="5" border="1" style="border-collapse:collapse;empty-cells:show; border-color:#666;margin:10px 0 10px 0;width:100%;">';
echo '<tr><th colspan="2">MySQL</th></tr>';
	$row = $xoopsDB->fetchRow($xoopsDB->query("SELECT version()"));
echo '<tr><td class="head" width="300">MySQL VERSION</td><td class="'. $ss_class[$count++%2] .'">'. h($row[0]) .'</td></tr>';
echo '<tr><td class="head">MySQL character_set</td><td class="'. $ss_class[$count++%2] .'">'. h(mysql_client_encoding()) .'</td></tr>';
	$sql = "SHOW TABLE STATUS LIKE '". $xoopsDB->prefix($mydirname.'_data') ."'";
	$result = $xoopsDB->queryF($sql);
	$row = $xoopsDB->fetchArray($result);
foreach ($row as $k => $v) {
	if (strtolower($k)=='name') {
		$v = str_replace(XOOPS_DB_PREFIX, '{prefix}', $v);
	}
	echo '<tr><td class="head">TABLE STATUS - '. h($k) .'</td><td class="'. $ss_class[$count++%2] .'">'. h($v) .'</td></tr>';
}
	$result = $xoopsDB->queryF("SHOW VARIABLES LIKE 'character%'");
while (list($key, $value) = $xoopsDB->fetchRow($result)) {
	echo '<tr><td class="head">VARIABLES - '. h($key) .'</td><td class="'. $ss_class[$count++%2] .'">'. h($value) .'</td></tr>';
}
echo '</table>';


xoops_cp_footer();
/* ------------------------------------------------------------------ */


function h($str, $quoteStyle = ENT_QUOTES, $char = _CHARSET)
{
	if (is_array($str)) {
		return array_map('h', $str);
	} else {
		return htmlspecialchars($str, $quoteStyle, $char);
	}
}
